/*
 * BlackLightning.PluginLib.ErrorMessage
 * Andy Tidball
 * 
 * Project: Black Lightning Plugin Library
 * Copyright: GNU General Public License
 */

using System;

namespace BlackLightning.PluginLib {
	/// <summary>
	/// A message that is sent to inform someone about an error.
	/// </summary>
	[Serializable]
	public class ErrorMessage : Message {
		// member data
		private Message   _Message;   // the message that caused this error message to occur
		private Exception _Exception; // the exception that caused this error message to occur

		/// <summary>
		/// Creates a new ErrorMessage.
		/// </summary>
		/// <param name="M">The message that was being handled when the error occurred.</param>
		public ErrorMessage(Message M)
			: this(M, null) {
		}

		/// <summary>
		/// Creates a new ErrorMessage.
		/// </summary>
		/// <param name="X">The exception that caused this message to occur.</param>
		public ErrorMessage(Exception X)
			: this(null, X) {
		}

		/// <summary>
		/// Creates a new ErrorMessage.
		/// </summary>
		/// <param name="M">The message that was being handled when the error occurred.</param>
		/// <param name="X">The exception that caused this message to occur.</param>
		public ErrorMessage(Message M, Exception X) {
			_Message   = M;
			_Exception = X;
		}

		/// <summary>
		/// Gets the Message that was being handled when the error occurred, or null if no message was being handled.
		/// </summary>
		public Message Message {
			get {
				return _Message;
			}
		}

		/// <summary>
		/// Gets the Exception that triggered this error message, or null if none triggered it.
		/// </summary>
		public Exception Exception {
			get {
				return _Exception;
			}
		}
	}
}
